<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>动弹</title>
    <link rel="stylesheet" type="text/css" href="../css/amazeui.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
     <link rel="stylesheet" type="text/css" href="../css/tngou.css" />
    <style>
    .tngou-line-clamp {
	 
	  text-overflow: ellipsis; 
	  overflow: hidden;
	  height: 50px;
	}
    </style>
</head>
<body>
	 <!-- 头部 -->	
<header data-am-widget="header" id="header"
          class="am-header am-header-default am-header-fixed"  >
      <h1 class="am-header-title">动弹</h1>  
      <div class="am-header-right am-header-nav">
          <a href="JavaScript:openWin('memo_add.html','send')" class="" >
                <i class="am-header-icon am-icon-send"></i>
          </a>
      </div>
</header>

<div class="am-margin">
<ul class="am-comments-list" id="list">

<!--<li class="am-comment am-comment-danger" onclick="url()">
<a href="#link-to-user-home" class="am-fl"><img src="http://s.amazeui.org/media/i/demos/bw-2014-06-19.jpg?imageView/1/w/96/h/96" alt="" class="am-comment-avatar" height="48" width="48"></a>
<div class="am-comment-main"><header class="am-comment-hd">
<div class="am-comment-meta">
<a href="#link-to-user" class="am-comment-author">某人</a> 发布于 <time>2014-7-14 23:301</time></div>
</header>
<div class="am-comment-bd">
<p class="tngou-line-clamp">　古曲建筑不仅何存完好，更是被绿植和鲜花覆盖，与周围景色融为一体浑然天成。此外，在景色基础上开发的农场旅店、庄园酒店，都被小溪、藤蔓、木桌、草坪环绕，放眼望去，真是赏心悦目。这里更有各种新奇有趣的节庆活动吸引无数运动爱好者前来参加，比如一年一度的已有400年历</p>
</div>
</div>
</li>-->

</ul>
</div>
        
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery.min.js"></script>
<script type="text/javascript" src="../script/amazeui.min.js"></script>
<script type="text/javascript" src="../script/config.js"></script>
<script type="text/javascript">
   var page=1;
	apiready = function(){

		page=getList(1, 'first');	// 首次加载
	// 下拉刷新
	api.setRefreshHeaderInfo({
	    visible: true,
	    bgColor: '#ccc',
	    textColor: '#fff',
	    textDown: '下拉刷新...',
	    textUp: '松开刷新...',
	    showTime: true
	}, function(ret, err){
	    //从服务器加载数据，完成后调用api.refreshHeaderLoadDone()方法恢复组件到默认状态
	    page=getList(1, 'refresh');
	});
	
	// 页面滑动到底部加载更多
	api.addEventListener({
		name:'scrolltobottom'
	},function(ret,err){		
		if(page > 1){
			page=getList(page, 'more');
		}
	    
	})	
		
	};
	

 function getList(page, type){

	if(type == 'more'){
		api.showProgress({
		    style: 'default',
		    animationType: 'fade',
		    modal: false
		});
	}
	
	var html = '';	
	api.ajax({
   
		url: OpenAPI.memo_list,
		method: 'post',
		timeout: 30,
		dataType: 'json',
		data:{
			values: {
				dataType: 'json',
				page: page,
			},
		},
		returnAll:false,
	    
	},function(ret,err){
	    if (ret.status) {
	        var total=ret.total;
	    	var list =ret.tngou;
			  	for(var i=0;i<list.length;i++){
			  	  var tngou=list[i];
			  	   var avatar="/avatar/default.jpg";
			    	if(tngou.avatar)avatar=tngou.avatar;
			    	var url="http://www.tngou.net/my/tngou/memo/"+tngou.id;	
			    	if(tngou.url)url=tngou.url;
			  	   html=html+'<li class="am-comment am-comment-danger"  onclick="url(\''+url+'\')">'+
					'<a href="#link-to-user-home" class="am-fl"><img src="'+TngouImg+avatar+'" alt="" class="am-comment-avatar" height="48" width="48"></a>'+
					'<div class="am-comment-main"><header class="am-comment-hd">'+
					'<div class="am-comment-meta">'+
					'<a href="#link-to-user" class="am-comment-author">'+tngou.account+'</a> 发布于 <time>'+format(tngou.time)+'</time></div>'+
					'</header>'+
					'<div class="am-comment-bd">'+
					'<p class="tngou-line-clamp">'+tngou.memo+'</p>'+
					'</div>'+
					'</div>'+
					'</li>';
			  	}
	    	
	        if(page > 1 && type=='more'){
	        	$api.append($api.dom('#list'), html);
	        }else{
	        	$api.html($api.dom('#list'), html);
	        }
	        api.parseTapmode();	        
	        if((parseInt(page)-1)*20>total)
	        {
		         api.toast({
				    msg: '数据全部加载，没有更多的数据',
				    duration:2000,
				    location: 'middle'
				});			
	        }	        
	        if(type == 'refresh'){
	        	api.refreshHeaderLoadDone();
	        }
	        

	    }else {
	        if(type == 'refresh'){
	        	api.refreshHeaderLoadDone();
	        }
			api.toast({
			    msg: '获取失败',
			    duration:2000,
			    location: 'middle'
			});
		
	    };
		api.hideProgress();
	});
    /***返回页面 */
	if(type=='more'){ return page+1;}else{return 2;}}
	
	
</script>
</html>